<template>
  <view>
    <view class="ge2"></view>

    <view class="ding">
      <view class="kk_ding">
        <view class="kk_ding_nei">
          <view class="tx">
            <image style="width: 100%;height: 100%" :src="detail.snapshoot.store_info.logo"></image>
          </view>
          <view class="name">{{ detail.snapshoot.store_info.name }}</view>
          <view></view>
        </view>

        <view class="zt">待付款</view>
      </view>

      <view class="kk_zhong">
        <view class="zhong_tx">
          <image style="width: 100%;height: 100%" :src="detail.snapshoot.cover"></image>
        </view>
        <view>
          <view class="zhong_h1">{{ detail.snapshoot.name }}</view>

          <view class="zhong_nk">
            <view>下单时间：</view>
            <view>{{ detail.create_time }}</view>
          </view>

          <view class="zhong_nk">
            <view>消费时段：</view>
            <view>{{ detail.start_time }} 至 {{ detail.end_time }}</view>
          </view>

          <view class="zhong_nk">
            <view>预定时段：</view>
            <view>{{ detail.start_time }}</view>
          </view>

          <view class="zhong_h1">总计 ￥{{ detail.price }}</view>
        </view>
      </view>
    </view>

    <view class="zhong">
      <view class="zhong_text">
        <view>订单总金额</view>
        <view>{{ detail.price }}</view>
      </view>

      <view class="zhong_text">
        <view>会员优惠</view>
        <view>{{ detail.price }}</view>
      </view>

      <view class="zhong_text">
        <view>在线支付</view>
        <view>{{ detail.price }}</view>
      </view>

      <view class="zhong_text2">
        <view>实付款</view>
        <view>￥{{ detail.price }}</view>
      </view>
    </view>

    <view class="ge2"></view>

    <view class="zhong">
      <view class="zhong_text2">订单信息</view>
      <view class="zhong_text3">
        <view>订单编号</view>
        <view class="bh">{{ detail.order_no }}</view>
        <view class="fz" @tap="copyone(detail.order_no)">复制</view>
      </view>

      <view class="zhong_text3">
        <view>创建时间</view>
        <view class="bh">{{ detail.create_time }}</view>
      </view>
    </view>

    <view class="ge2"></view>

    <view class="kk_di">
      <view class="di_qx" @tap="canceloreder(detail.id)">
        <view>取消订单</view>
      </view>
      <view class="di_jx" @tap="showModasl()">
        <view>继续付款</view>
      </view>
    </view>

    <view class="page">
      <!-- 页面内容 -->
      <view class="modal" v-if="modalVisible">
        <view class="modal-header">
          <image class="close-btn" @tap="closeModal" src="/static/pages/img/x .png"></image>
        </view>
        <image class="qr-code" :src="qrCodeUrl"></image>
        <view>请使用微信扫一扫完成支付</view>
      </view>
      <view class="mask" v-if="modalVisible" @tap="closeModal"></view>
    </view>
  </view>
</template>

<script>
// pages/dingdanxiangqing/dingdanxiangqing.js
import {houseordercancelOrder, houseorderdetails} from "@/common/api";

export default {
  data() {
    return {
      // 控制模态框显示与隐藏
      modalVisible: false,
      qrCodeUrl: '',
      detail: {}
    };
  }
  /**
   * 生命周期函数--监听页面加载
   */,
  onLoad(options) {
    console.log('onLoad', options)
    houseorderdetails({
      order_id: options.id
    }, res => {
      if (res.data.code == 0) {
        this.detail = res.data.data
      }
      console.log('houseorderdetails', res)
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  methods: {
    // 复制
    copyone: function (copydata) {
      uni.setClipboardData({
        data: copydata, // e是你要保存的内容
        success: function () {
          uni.showToast({
            title:'复制成功',
            duration: 2000,
            mask: true // 设置为true，使背景半透明
          })
        }
      })
    },

    closeModal: function () {
      uni.showToast({
        title: '取消支付',
        icon: 'none',
        duration: 2000,
        mask: true,
        // 设置为true，使背景半透明
        success: () => {
          setTimeout(() => {
            this.setData({
              modalVisible: false
            });
          }, 2000);
        }
      });
    },

    // 点击按钮显示模态框
    showModasl: function () {
      let item = this.detail;
      uni.navigateTo({
        url: "/packageB/dingdanzhifu/dingdanzhifu?mpaytype=2&order_id=" + item.id + "&pay_type=" + item.pay_type + "&type=" + item.type + "&end=" + item.end_time + "&start=" + item.start_time + "&house_id=" + item.house_id
      })
    },
    // 取消订单
    canceloreder: function (order_id) {
      uni.showModal({
        title: '确认取消',
        content: '确认要取消此订单吗',
        success: function (res) {
          if (res.confirm) {
            uni.showLoading({
              title: '操作中...'
            });
            houseordercancelOrder({
              order_id: order_id
            }, ssres => {
              uni.hideLoading();
              if (ssres.data.code == 0) {
                uni.navigateBack({delta: 1})
              }
            }, fail => {
              uni.hideLoading();
              uni.showModal({
                title: "操作失败",
                showCancel: false
              });
            })
          } else if (res.cancel) {
            console.log('取消');
          }
        }
      });
    },

    fukuanone: function () {
    }
  }
};
</script>
<style>
.ding {
  border-bottom: 1rpx solid rgba(129, 129, 129, 0.363);
}

.kk_ding {
  display: flex;
  align-items: center;
  padding: 20rpx;
  font-size: 32rpx;
  margin-left: 20rpx;
}

.kk_ding_nei {
  display: flex;
  margin-right: 300rpx;
  align-items: center;
  font-weight: bold;
}

.tx {
  width: 50rpx;
  height: 50rpx;
  background-color: white;
  border-radius: 50%;
  margin-right: 10rpx;
}

.zt {
  color: rgb(204, 144, 13);
}

.kk_zhong {
  display: flex;
  margin: 20rpx 0rpx 20rpx 0rpx;
  padding: 0 0 0 40rpx;
}

.zhong_tx {
  width: 130rpx;
  height: 130rpx;
  background-color: blue;
  margin-right: 10rpx;
  border-radius: 5px; /* 圆角设置为20px */
}

.zhong_nk {
  display: flex;
  color: rgb(129, 129, 129);
  font-size: 27rpx;
  line-height: 2;
}

.zhong_h1 {
  font-weight: bold;
  font-size: 31rpx;
  margin-bottom: 10rpx;
}

.zhong {
  padding: 40rpx;
  color: rgb(104, 104, 104);
}

.zhong_text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40rpx;
}

.zhong_text2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #000;
  font-weight: bold;
}

.zhong_text3 {
  display: flex;
  margin-bottom: 40rpx;
  margin-top: 50rpx;
  font-size: 28rpx;
}

.bh {
  margin-left: 40rpx;
  margin-right: 10rpx;
}

.fz {
  background-color: rgba(224, 224, 224, 0.377);
  font-size: 25rpx;
  padding: 3rpx 7rpx 3rpx 7rpx;
  border-radius: 4px; /* 圆角设置为20px */
}

.kk_di {
  display: flex;
  justify-content: flex-end;
  font-size: 30rpx;
  margin: 40rpx 20rpx 30rpx 0;
}

.di_qx {
  border: 1px solid rgb(175, 175, 175);
  border-radius: 4px; /* 圆角设置为20px */
  padding: 10rpx 20rpx 10rpx 20rpx;
  margin-right: 30rpx;
}

.di_jx {
  background-color: rgb(126, 212, 155);
  border-radius: 4px; /* 圆角设置为20px */
  padding: 10rpx 20rpx 10rpx 20rpx;
  margin-right: 20rpx;
  color: rgb(255, 255, 255);
}

.page {
  position: relative;
  width: 100%;
  height: 100vh;
}

.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色 */
  z-index: 999; /* 确保遮罩层在最上层 */
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 0 70rpx 100rpx 70rpx;
  border-radius: 8rpx;
  z-index: 1000; /* 确保模态框在遮罩层上面 */
}

.modal-header {
  display: flex;
  justify-content: flex-end;
}

.close-btn {
  color: black;
  cursor: pointer;
  margin: 30rpx -40rpx 120rpx 0rpx;
  width: 20rpx;
  height: 20rpx;
}

.qr-code {
  display: block;
  margin-top: 20px;
  width: 400rpx;
  height: 400rpx;
}
</style>
